# import wx
# import wx.aui
#
#
# class Test2_Frame(wx.Frame):
#     def __init__(self, parent, title):
#         super(Test2_Frame, self).__init__(parent, title=title, size=(800, 600))
#         panel = wx.Panel(self)
#
#         notebook = wx.aui.AuiNotebook(panel,
#                                       style=wx.aui.AUI_NB_TOP |
#                                             wx.aui.AUI_NB_TAB_SPLIT |
#                                             wx.aui.AUI_NB_TAB_MOVE |
#                                             wx.aui.AUI_NB_SCROLL_BUTTONS |
#                                             wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)
#
#         # 添加页面到auinetobook
#         self.page1 = self.create_page(notebook, "页面1")
#         self.page2 = self.create_page(notebook, "页面2")
#         self.page3 = self.create_page(notebook, "页面3")
#
#         notebook.AddPage(self.page1, "页面1")
#         notebook.AddPage(self.page2, "页面2")
#         notebook.AddPage(self.page3, "页面3")
#
#         self.Bind(wx.EVT_CLOSE, self.OnClose)
#         sizer = wx.BoxSizer(wx.VERTICAL)
#         sizer.Add(notebook, 1, wx.EXPAND)
#         panel.SetSizer(sizer)
#         self.SetSizer(wx.BoxSizer(wx.VERTICAL))
#         self.GetSizer().Add(panel, 1, wx.EXPAND)
#
#
#     def OnClose(self, event):
#         self.Destroy()
#
#     def create_page(self, notebook, label):
#         page = wx.Panel(notebook)
#         if label == "页面1":
#             button = wx.Button(page, label="显示消息", pos=(10, 10))
#             button.Bind(wx.EVT_BUTTON, self.on_page1_button)
#         elif label == "页面2":
#             static_text = wx.StaticText(page, label="我是页面2", pos=(10, 10))
#         elif label == "页面3":
#             static_text = wx.StaticText(page, label="", pos=(10, 10))
#             page.static_text = static_text
#             button = wx.Button(page, label="更新标签", pos=(100, 100))
#             button.Bind(wx.EVT_BUTTON, self.on_page3_button)
#
#     def on_page1_button(self, event):
#         wx.MessageBox("这是一个消息框")
#
#     def on_page3_button(self, event):
#         static_text = self.page3.static_text
#         static_text.SetLabel("我是页面3")
#
# app = wx.App(False)
# frame = Test2_Frame(None)
# frame.Show(True)
# app.MainLoop()
#
import wx
import wx.aui


class Test2_Frame(wx.Frame):
    def __init__(self, parent, title):
        super(Test2_Frame, self).__init__(parent, title=title, size=(800, 600))
        panel = wx.Panel(self)

        notebook = wx.aui.AuiNotebook(panel,
                                      style=wx.aui.AUI_NB_TOP |
                                            wx.aui.AUI_NB_TAB_SPLIT |
                                            wx.aui.AUI_NB_TAB_MOVE |
                                            wx.aui.AUI_NB_SCROLL_BUTTONS |
                                            wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)

        # 添加页面到auinetobook
        self.page1 = self.create_page(notebook, "页面1")
        self.page2 = self.create_page(notebook, "页面2")
        self.page3 = self.create_page(notebook, "页面3")

        notebook.AddPage(self.page1, "页面1")
        notebook.AddPage(self.page2, "页面2")
        notebook.AddPage(self.page3, "页面3")

        self.Bind(wx.EVT_CLOSE, self.OnClose)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(notebook, 1, wx.EXPAND)
        panel.SetSizer(sizer)
        self.SetSizer(wx.BoxSizer(wx.VERTICAL))
        self.GetSizer().Add(panel, 1, wx.EXPAND)

    def OnClose(self, event):
        self.Destroy()

    def create_page(self, notebook, label):
        page = wx.Panel(notebook)
        if label == "页面1":
            button = wx.Button(page, label="显示消息", pos=(10, 10))
            button.Bind(wx.EVT_BUTTON, self.on_page1_button)
        elif label == "页面2":
            static_text = wx.StaticText(page, label="我是页面2", pos=(10, 10))
        elif label == "页面3":
            static_text = wx.StaticText(page, label="", pos=(10, 10))
            page.static_text = static_text
            button = wx.Button(page, label="更新标签", pos=(100, 10))
            button.Bind(wx.EVT_BUTTON, self.on_page3_button)
        return page  # 添加返回语句

    def on_page1_button(self, event):
        wx.MessageBox("这是一个消息框")

    def on_page3_button(self, event):
        static_text = self.page3.static_text
        static_text.SetLabel("我是页面3")


class myapp(wx.App):
    def OnInit(self):
        myframe = Test2_Frame(None, title="测试窗口")  # 添加标题参数
        myframe.Show(True)
        return True


if __name__ == '__main__':
    app = myapp()
    app.MainLoop()
